﻿//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Web;
//using System.Web.Mvc;
//using log4net;
//using KLS.PPDS.Utilities.BaseController;
////using System.Web.Mvc;
//namespace System.Web.Mvc
//{
//    public partial class  Controller : BaseController
//    {
//        private static readonly ILog log = LogManager.GetLogger(typeof(Controller));

//        /// <summary>
//        /// This is controller common error handler
//        /// for showing error message please use OnComplete/OnSucess method to receve json error message
//        /// </summary>
//        /// <param name="filterContext"></param>
//        protected override void OnException(ExceptionContext filterContext)
//        {

//            if (filterContext == null)
//            {
//                return;
//            }
//            if (filterContext.Exception != null)
//            {
//                // filterContext.Exception.ErrorLog();
//                log.Error(filterContext.Exception);
//            }

//            if ((filterContext.HttpContext.Request.IsAjaxRequest() && filterContext.Exception != null) || filterContext.Exception != null)
//            {
//                filterContext.HttpContext.Response.StatusCode = (int)System.Net.HttpStatusCode.InternalServerError;
//                //filterContext.Result = new JavaScriptResult() { Script = "alert(hi);" };

//                filterContext.Result = new JsonResult()
//                {
//                    JsonRequestBehavior = JsonRequestBehavior.AllowGet,
//                    // ContentType = "application/json; charset=utf-8",
//                    Data = new
//                    {
//                        Message = filterContext.Exception.Message,
//                        StackTrace = filterContext.Exception.StackTrace,
//                        Result = true
//                    }
//                };
//                filterContext.ExceptionHandled = true;
//            }
//            //filterContext.RequestContext.HttpContext.Response.R
//            //base.OnException(filterContext);
//        }
//    }
//}